package com.cgbl.service.adapter

import com.blankj.utilcode.util.TimeUtils
import com.cgbl.service.R
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.robot.base.model.ProjectBean
import com.robot.base.utils.pic.ImageLoaderUtils

class ProjectListAdapter :
    BaseQuickAdapter<ProjectBean, BaseViewHolder>(R.layout.app_item_project_list) {

    override fun convert(holder: BaseViewHolder, item: ProjectBean) {
        ImageLoaderUtils.display(context, holder.getView(R.id.iv_cover), item.itemFile)
        holder.setText(R.id.tv_type, item.labelName)
        when (item.status) {
            "0" -> {
                holder.setText(R.id.tv_label, "审核中")
                holder.setBackgroundResource(R.id.tv_label, R.drawable.app_bg_project_state_audit)
            }

            "1" -> {
                holder.setText(R.id.tv_label, "待启动")
                holder.setBackgroundResource(R.id.tv_label, R.drawable.app_bg_project_state_audit)
            }

            "2" -> {
                holder.setText(R.id.tv_label, "已付款")
                holder.setBackgroundResource(
                    R.id.tv_label, R.drawable.app_bg_project_state_complete
                )
            }

            "3" -> {
                holder.setText(R.id.tv_label, "开发中")
                holder.setBackgroundResource(R.id.tv_label, R.drawable.app_bg_project_state_develop)
            }

            "4" -> {
                holder.setText(R.id.tv_label, "已完成")
                holder.setBackgroundResource(R.id.tv_label, R.drawable.app_bg_project_state_close)
            }

            "5" -> {
                holder.setText(R.id.tv_label, "已结算")
                holder.setBackgroundResource(R.id.tv_label, R.drawable.app_bg_project_state_close)
            }
        }
        holder.setText(R.id.tv_name, item.itemName)
        holder.setText(
            R.id.tv_time,
            TimeUtils.millis2String(item.createTime?.toLong() ?: 0, "yyyy-MM-dd hh:mm:ss")
        )
    }

}